home *** CD-ROM | disk | FTP | other *** search
- Path: news.rain.org!usenet
- From: "Guus Leeuw jr." <guusl@eiffel.com>
- Newsgroups: comp.lang.c++
- Subject: Re: main()
- Date: Wed, 17 Apr 1996 21:05:28 -0700
- Organization: Interactive Software Engineering Inc. http://www.eiffel.com/
- Message-ID: <3175BF88.5D42A0B6@eiffel.com>
- References: <3174c0dc.7652220@news.flex.com.au> <829766541snz@j-bg.demon.co.uk> <Dq1C8B.3sC@news.hawaii.edu>
- NNTP-Posting-Host: @outback.eiffel.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (X11; I; Linux 1.2.8 i586)
- CC: Alvin Nonaka <xea0005@co.honolulu.hi.us>
-
- Alvin Nonaka wrote:
- >
-
- [snip snip]
-
- >
- > I believe the authors intended to say:
- >
- > #include <stdio.h>
- > #include <stdlib.h>
- > void main(void)
- > {
- > printf("Hello!\n");
- > exit(0);
- > }
- >
- > 'main' can't return. Calling 'exit' is better because the call to exit
-
- What? `main' cannot return? What about:
- int main()
- {
- return 0;
- }
-
- You mean that the whole world (plus the ANSI C Comittee) has been wring on
- this for years. That all portable code is not portable, etc.etc?
-
- > 'cleans up' all resource allocations (which you are supposed to handle)
- > left pending in your code.
-
- `exit' does this, but if there are no allocated resources, why call `exit'?
- Just return from main will do very good...
-
- >
- > The value passed to exit is 'returned' and control passes to the host
- > environment.
-
- The value returned from `int main()' is returned and process control passes
- it to the host environment.
-
- --
- 'l8r,
- Guus
- ---------------------------------------------------------------------------
- They say I'm wild and I'm reckless.
- -- Jim Steinman (from the song: Everything louder than everything else)
- ---------------------------------------------------------------------------
-